#include "UVisDataProvider.h"

UTypedDataProvider_Internal<float, FOnFloatProvided>* UVisDataProvider::GetFloatProviderByIndex(int index)
{
	if (FloatProviders_ == nullptr) {
		FloatProviders_ = MakeUnique< FTypedDataProviderContainer<float, FOnFloatProvided> >();
	}

	return FloatProviders_->GetProviderByIndex(index);
}
UTypedDataProvider_Internal<int, FOnIntProvided>* UVisDataProvider::GetIntProviderByIndex(int index)
{
	if (IntProviders_ == nullptr) {
		IntProviders_ = MakeUnique< FTypedDataProviderContainer<int, FOnIntProvided> >();
	}

	return IntProviders_->GetProviderByIndex(index);
}

UTypedDataProvider_Internal<bool, FOnBoolProvided>* UVisDataProvider::GetBoolProviderByIndex(int index)
{
	if (BoolProviders_ == nullptr) {
		BoolProviders_ = MakeUnique< FTypedDataProviderContainer<bool, FOnBoolProvided> >();
	}

	return BoolProviders_->GetProviderByIndex(index);
}

UTypedDataProvider_Internal<FString, FOnStringProvided>* UVisDataProvider::GetStringProviderByIndex(int index)
{
	if (StringProviders_ == nullptr) {
		StringProviders_ = MakeUnique< FTypedDataProviderContainer<FString, FOnStringProvided> >();
	}

	return StringProviders_->GetProviderByIndex(index);
}

void UVisDataProvider::ProvideFloatDataByIndex(int index, float data)
{
	auto provider = GetFloatProviderByIndex(index);
	checkf(provider != nullptr, TEXT("Failed to get or create float data provider at index %d"), index);
	provider->ProvideData(data);
}
void UVisDataProvider::ProvideIntDataByIndex(int index, int data)
{
	auto provider = GetIntProviderByIndex(index);
	checkf(provider != nullptr, TEXT("Failed to get or create int data provider at index %d"), index);
	provider->ProvideData(data);
}

void UVisDataProvider::ProvideBoolDataByIndex(int index, bool data)
{
	auto provider = GetBoolProviderByIndex(index);
	checkf(provider != nullptr, TEXT("Failed to get or create bool data provider at index %d"), index);
	provider->ProvideData(data);
}

void UVisDataProvider::ProvideStringDataByIndex(int index, FString& data)
{
	auto provider = GetStringProviderByIndex(index);
	checkf(provider != nullptr, TEXT("Failed to get or create string data provider at index %d"), index);
	provider->ProvideData(data);
}

void UVisDataProviderComponent::ProvideFloatDataByIndex(int index, float data)
{
	DataProvider_.ProvideFloatDataByIndex(index, data);
}
void UVisDataProviderComponent::ProvideIntDataByIndex(int index, int data)
{
	DataProvider_.ProvideIntDataByIndex(index, data);
}
void UVisDataProviderComponent::ProvideBoolDataByIndex(int index, bool data)
{
	DataProvider_.ProvideBoolDataByIndex(index, data);
}
void UVisDataProviderComponent::ProvideStringDataByIndex(int index, FString data)
{
	DataProvider_.ProvideStringDataByIndex(index, data);
}

UTypedDataProvider_Internal<float, FOnFloatProvided>* UVisDataProviderComponent::GetFloatProviderByIndex(int index)
{
	return DataProvider_.GetFloatProviderByIndex(index);
}
UTypedDataProvider_Internal<int, FOnIntProvided>* UVisDataProviderComponent::GetIntProviderByIndex(int index)
{
	return DataProvider_.GetIntProviderByIndex(index);
}
UTypedDataProvider_Internal<bool, FOnBoolProvided>* UVisDataProviderComponent::GetBoolProviderByIndex(int index)
{
	return DataProvider_.GetBoolProviderByIndex(index);
}
UTypedDataProvider_Internal<FString, FOnStringProvided>* UVisDataProviderComponent::GetStringProviderByIndex(int index)
{
	return DataProvider_.GetStringProviderByIndex(index);
}

void UVisDataProviderComponent::BeginPlay()
{
	Super::BeginPlay();
}

void UVisDataProviderComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
